package pack0625;

public class Demo1 {
    //定义属性
    int a;
    int b;
    public void swap(int a,int b){
        int p =a;
        a=b;
        b=p;
        this.a = a;
        this.b = b;
        System.out.println("方法内部："+a+":"+b);
    }
    public static void main(String[] args) {
        //测试 值传递
        int a = 10;
        int b = 20;
        System.out.println("交换前：a=" + a + ",b=" + b);//
        Demo1 d=new Demo1();
        d.swap(a,b);//将值赋到属性a，b
        System.out.println("交换后：a="+d.a+",b="+d.b);
        System.out.println(a+","+b);
    }
}

